package swagger2.handler;

import io.swagger.annotations.ApiModelProperty;

import java.util.List;

public class ApiResult<T>
{

	@ApiModelProperty("是否成功")
	private Boolean success;

	@ApiModelProperty("状态")
	private Integer state = null;

	@ApiModelProperty("消息")
	private String message = null;

	@ApiModelProperty("单条数据")
	private T data = null;

	@ApiModelProperty("数据列表")
	private List<T> datalist = null;

	@ApiModelProperty("分页信息")
	private Page page = null;

	public ApiResult<T> success()
	{
		this.success = true;
		return this;
	}

	public ApiResult<T> state(Integer state)
	{
		this.success = true;
		this.state = state;
		return this;
	}

	public ApiResult<T> message(String message)
	{
		this.success = true;
		this.message = message;
		return this;
	}

	public ApiResult<T> data(T data)
	{
		this.success = true;
		this.data = data;
		return this;
	}

	public ApiResult<T> datalist(List<T> datalist)
	{
		this.success = true;
		this.datalist = datalist;
		return this;
	}

	public ApiResult<T> page(Page page)
	{
		this.success = true;
		this.page = page;
		return this;
	}

	public ApiResult<T> page(Page page, List<T> datalist)
	{
		this.success = true;
		this.page = page;
		this.datalist = datalist;
		return this;
	}

	public ApiResult<T> page(Page page, T data)
	{
		this.success = true;
		this.page = page;
		this.data = data;
		return this;
	}

	public ApiResult<T> failure()
	{
		this.success = false;
		return this;
	}

	public ApiResult<T> failure(String message)
	{
		this.success = false;
		this.message = message;
		return this;
	}

	public Boolean getSuccess()
	{
		return success;
	}

	public Integer getState()
	{
		return state;
	}

	public String getMessage()
	{
		return message;
	}

	public T getData()
	{
		return data;
	}

	public List<T> getDatalist()
	{
		return datalist;
	}

	public Page getPage()
	{
		return page;
	}
}
